#pragma once
//disables warning messages that would fly as a result of this implementation
#pragma warning (disable:4786)

#include <set>

#include "Telegram.h"

class GameObject;

// for your pleasure.
const double SEND_MSG_IMMEDIATELY = 0.0f;
const int   NO_ADDITIONAL_INFO   = 0;

#define Handler MessageHandler::Instance()

class MessageHandler
{
private:  

  //this method is utilized by DispatchMessage or DispatchDelayedMessages.
  //This method calls the message handling member function of the receiving
  //entity, pReceiver, with the newly created telegram
  void Discharge(GameObject* pReceiver, const Telegram& msg);

  MessageHandler(){}

  //copy ctor and assignment should be private
  MessageHandler(const MessageHandler&);
  MessageHandler& operator=(const MessageHandler&);

public:

  //this class is a singleton
  static MessageHandler* Instance();

  //send a message to another agent. Receiving agent is referenced by ID.
  void SendMessage(double  delay,
                       int    sender,
                       int    receiver,
                       int    msg,
                       void*  ExtraInfo);
};
